home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_26 / ncounter.asm < prev    next >
Assembly Source File  |  1995-01-01  |  3KB  |  70 lines

  1.  
  2. code_seg        segment
  3.         assume  cs:code_seg
  4.         org     100h
  5.         jmp     start
  6. ;----------------------------------
  7. ;B/C Software                        ;Author
  8. ;520 North Stateline Rd
  9. ;Sharon, Pa 16146
  10. ;----------------------------------
  11. message1 db     'press Esc to Quit',0dh,0ah,'$'   ;Esc to end close encounter
  12. message2 db     'press any other key to play$'    ;or to go again
  13. ;-----------------------------------------------------------------------------
  14.                      ;note + delay count
  15. muzic_notes  dw      1521,0015, 1355,0015, 1715,0015, 3416,0015h 
  16.              dw      2280,0030, 0ffffh   ;theme of "close encounter"
  17. ;-----------------------------------------------------------------------------
  18. start   proc    near
  19.         mov     ah,9                 ;DOS function number to print string
  20.         mov     dx,offset message1   ;the message
  21.         int     21h                  ;DOS interrupt
  22.         mov     ah,9                 ;DOS function number to print string
  23.         mov     dx,offset message2   ;the message
  24.         int     21h                  ;DOS interrupt
  25. begin:  mov     ah,0                 ;BIOS function wait for key press
  26.         int     16h                  ;BIOS interrupt
  27.         cmp     ah,1                 ;Esc scan code 
  28.         jz      done                 ;do we stop ?
  29.         call    play                 ;no call play
  30.         jmp     begin                ;go see if we do it again
  31. done:   mov     ax,4c00h             ;no exit back to DOS
  32.         int     21h                  ;DOS interrupt
  33. start   endp
  34. ;-------------------------------------------
  35. play    proc    near
  36.         cli                          ;interrupts off
  37.         lea     si,muzic_notes       ;point (si) to our note table
  38. play2:  cld                          ;must increment forward
  39.         lodsw                        ;load word into ax and increment (si)
  40.         cmp     ax,0ffffh            ;is it ffff - if so end of table
  41.         jz      x_muzic2             ;time to quit
  42.         push    ax                   ;push our note value on the stack
  43.         mov     al,10110110xb        ;the magic number
  44.         out     43h,al               ;send it
  45.         pop     ax                   ;pop our note value off the stack
  46.         out     42h,al               ;send LSB first
  47.         mov     al,ah                ;place MSB in al
  48.         out     42h,al               ;send it next
  49.         in      al,61h               ;get value to turn on speaker
  50.         or      al,00000011xb        ;OR the gotten value
  51.         out     61h,al               ;now we turn on speaker
  52.         lodsw                        ;load the repeat loop count into (ax)
  53. loop6:  mov     cx,10000             ;first delay count
  54. loop7:  loop    loop7                ;do the delay
  55.         dec     ax                   ;decrement repeat count
  56.         jnz     loop6                ;if not = 0 loop back
  57.         in      al,61h               ;all done
  58.         and     al,11111100xb        ;number turns speaker off
  59.         out     61h,al               ;send it
  60.         mov     cx,5000              ;second delay count
  61. loop8:  loop    loop8                ;wait a bit before next note
  62.         jmp     short play2          ;now go do next note
  63. x_muzic2:
  64.         sti                          ;enable interrupts
  65.         ret
  66. play    ends
  67. ;-------------------------------------------
  68. code_seg        ends
  69.  
  70.